package com.example.myservlet;

import com.example.anno.RequestMapping;
import com.example.mybatis.model.User;
import com.example.mybatis.service.UserService;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

@Slf4j
@RequestMapping("/mybatis")
public class MybatisTestServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
        UserService userService = new UserService();

        // 测试插入
        User newUser = new User();
        newUser.setName("John Doe");
        newUser.setEmail("john.doe@example.com");
        userService.insertUser(newUser);

        // 测试查询
        User user = userService.getUserById(1);
        System.out.println("User: " + user.getName() + ", Email: " + user.getEmail());
    }

}